<template>
  <div class="hello">
    <div>
      <h2>mapGetters</h2>
      <div style="color: red;">1、GETTER内容：</div>
      <br />
      <p>{{ this.$store.getters.doneTodos }}</p>
      <div style="color: red;">2、Getter 也可以接受其他 getter 作为第二个参数：如：将state的值进行处理</div>

      <p>{{ this.$store.getters.doneTodosCount }}</p>
      <div style="color: red;">3、通过让 getter 返回一个函数，来实现给 getter 传参。对store 里的数组进行查询时非常有用。</div>
      <p>
        eg:返回id为2的项
        <br />
        {{ this.$store.getters.getById(2) }}
      </p>
      <div style="color: red;">4、通过mapgetters获取值</div>
      <p>{{ doneTodos }}</p>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  methods: {},
  computed: {
    localComputed () {
      return '88888'
    },
    // 使用对象展开运算符将此对象混入到外部对象中
    ...mapGetters(['doneTodos'])
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
